%by clq
%need to input best_is,opt_profits,opt_profits_pref,profits_R,profits_RP
%p=(0.1,0.5,0.9)
%call_in_sequence=[2 2 1 3 3 3 3 3 2 2 1 2 3 3 3 3 1 1 2 1 3 1 2 3 1 1 1 2 3 1 2 3 3 1 2 1 3 3 2 2 2 1 1 2 1 1 2 1]
function[]=figure2(best_is,opt_profits,opt_profits_pref,profits_R,profits_RP)
figure(2)
n=length(best_is);

%first draw the expected profit
yyaxis left;
plot(1:n,opt_profits,'-');
hold on; plot(1:n,profits_R,'--');
hold on; plot(1:n,opt_profits_pref,'.:');
hold on; plot(1:n,profits_RP,'.--');
legend('Proposed Policy','Round Robin','Prop. Policy with Pref.','Round Robin with Pref.','Location','NorthWest')

%then mark the best slot
yyaxis right;
hold on; stem(1:n,best_is,'o:');

%labels on the axis
ylim([0 9])
yticks([1 2 3 4 5 6 7 8 9]);
yticklabels({'1:(0,2,3)','2:(1,1,2)','3:(2,2,1)','4:(2,2,1)','5:(1,0,2)','6:(3,1,2)','7:(0,0,2)','8:(2,1,1)',''});
yyaxis left;
ylabel('Expected Profit');
xlabel('Sequence of patient types');
xticks([1:48])
xticklabels({'2','2','1','3','3','3','3','3','2','2','1','2','3','3','3','3','1','1','2','1','3','1','2','3','1','1','1','2','3','1','2','3','3','1','2','1','3','3','2','2','2','1','1','2','1','1','2','1'});


%lines and marks (to be adjusted)
hold on; line([28,28],[0,1800],'LineWidth',3);
hold on; line([35,35],[0,1800],'LineWidth',3);
annotation('textarrow',[0.5 0.56],[0.8889 0.8889],'string','Patient 28');
annotation('textarrow',[0.74 0.68],[0.8889 0.8889],'string','Patient 35');
annotation('textarrow',[0.46 0.46],[0.7222 0.6667],'string','Patient 23');
annotation('textarrow',[0.7 0.7],[0.4722 0.5278],'string','Patient 35');
annotation('textarrow',[0.86 0.86],[0.3889 0.4444],'string','Patient 43');